//
//  FCMessageViewController.swift
//  FinancialConsulting
//
//  Created by Max on 2017/10/31.
//  Copyright © 2017年 com.vector. All rights reserved.
//

import UIKit

class FCMessageViewController: FCViewController ,UITableViewDataSource, UITableViewDelegate{

    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var oneButton: UIButton!
    @IBOutlet weak var threeButton: UIButton!

    @IBOutlet weak var twoButton: UIButton!
    @IBOutlet weak var imageButton: UIButton!
    @IBOutlet weak var imageLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "我的消息"
        
        tableView.tableFooterView = UIView()
        imageLabel.isHidden = true
        imageButton.isHidden = true
        self.oneButton.setBackgroundImage(UIImage(named:"33"),for: .normal)
        self.twoButton.setBackgroundImage(UIImage(named:"33"),for: .normal)
        self.threeButton.setBackgroundImage(UIImage(named:"33"),for: .normal)
        self.oneButton.setBackgroundImage(UIImage(named:"34"),for: .selected)
        self.twoButton.setBackgroundImage(UIImage(named:"34"),for: .selected)
        self.threeButton.setBackgroundImage(UIImage(named:"34"),for: .selected)

        
       // if oneButton.tag == 0 {
        
        //    self.oneButton.setBackgroundImage(UIImage(named:"34"),for: .normal)
       // }
    }
    
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return 2
        
    }
    
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = UITableViewCell()
        
        cell = tableView.dequeueReusableCell(withIdentifier: FCMessageCell.name,for: indexPath)
        
        if let messageCell = cell as? FCMessageCell {
        
            if indexPath.row == 0 {
            
                messageCell.titleLabel.text = "怎么提高信用卡固定额度>>"
                
            }else {
                messageCell.titleLabel.text = "信用卡分期买车划算吗？有没有优缺点？>>"
                
            
            }
        }
      
        return cell
    }

    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let v = FCCenterViewController()
        self.navigationController?.pushViewController(v, animated: true)
        
    }
    
    
    @IBAction func oneAction(_ sender: UIButton) {
 
        
        if oneButton == sender{
          
        }else {
        
            self.oneButton.setBackgroundImage(UIImage(named:"33"),for: .normal)
            sender.setBackgroundImage(UIImage(named:"34"),for: .normal)
           
            
            if sender.tag == 0 {
            
            
                tableView.isHidden = false
                imageButton.isHidden = true
                imageLabel.isHidden = true
            }
            
            
        }
        
        oneButton = sender
        
        if twoButton == sender{
            
        }else {
            
            self.twoButton.setBackgroundImage(UIImage(named:"33"),for: .normal)
            sender.setBackgroundImage(UIImage(named:"34"),for: .normal)
          
            if sender.tag == 1 {
                tableView.isHidden = true
                imageButton.isHidden = false
                imageLabel.isHidden = false
                imageLabel.text = "暂无交易消息"
            }
            
        }
        
        twoButton = sender
        

        if threeButton == sender{
            
        }else {
            
            self.threeButton.setBackgroundImage(UIImage(named:"33"),for: .normal)
            sender.setBackgroundImage(UIImage(named:"34"),for: .normal)
        
            if sender.tag == 2 {
                  tableView.isHidden = true
                  imageButton.isHidden = false
                  imageLabel.isHidden = false
                  imageLabel.text = "暂无站内消息"
            }
        }
        
        threeButton = sender
    }
    
    
   
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

   
    
}
